// pages/poet/poet.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inpvalue:'',
    answer:'',
    yes:'',
    appear:'dis',
    isshow:'dis',
  },

  onLoad: function () {
    this.getData();
  },
  getData:function(){
    let self = this
    wx.request({
      url: 'https://wx.original5.xyz:2003/game/game3/detail', 
      method:'GET',
      header: {
        'content-type': 'application/json' 
      },
      success: function (res) {
        console.log(res.data)
        let result = res.data;
        var index = Math.floor((Math.random()*(result.length))); 
        var arr = result[index].dcontent.split("，");
        console.log(result[index])
        console.log(arr)
        self.data.answer=result[index].danswer
        self.setData({
          result:result[index],
          iconStyle:arr,
          appear:'dis', 
          isshow:'dis' 
        })   
      }
    })
  },

  bindinp:function(e){
    this.data.inpvalue = e.detail.value;
  },

  exitclick: function () {
    wx.reLaunch({
      url: '/pages/game/game'
    })
  },

   subclick: function () {
    var inpvalue=this.data.inpvalue
    var answer=this.data.answer
    console.log(inpvalue)
    console.log(answer)
      if(inpvalue==answer){
        this.data.yes='right'
      }else{
        this.data.yes='mistake'
      }
    console.log(this.data.yes)
    this.setData({
      yes:this.data.yes,
      appear: ' ', 
      isshow:'show',    
    })

    
  },
  nextclick: function () {
    wx.navigateTo({
      url:"/pages/poet/poet"
    })
  },



  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})